Learn R Programming

penalized (version 0.9-52)

Prediction from penalized models: Prediction based on penfit objects

Description

Predicting a response for new subjects based on a fitted penalized regression model.

Usage

# S4 method for penfit
predict(object, penalized, unpenalized, data)

Arguments

object

The fitted model (a penfit object).

penalized

The matrix of penalized covariates for the new subjects.

unpenalized

The unpenalized covariates for the new subjects.

data

A data.frame used to evaluate the terms of penalized or unpenalized when these have been specified as a formula object.

Value

The predictions, either as a vector (logistic and Poisson models), a matrix (linear model), or a breslow object (Cox model).

Details

The user need only supply those terms from the original call that are different relative to the original call that produced the penfit object. In particular, if penalized and/or unpenalized was specified in matrix form, a matrix must be given with the new subjects' data. The columns of these matrices must be exactly the same as in the matrices supplied in the original call that produced the penfit object. If either penalized or unpenalized was given as a formula in the original call, the user of predict must supply a new data argument. As with matrices, the new data argument must have a similar make-up as the data argument in the original call that produced the penfit object. In particular, any factors in data must have the same levels.

Examples

Run this code
# NOT RUN {
data(nki70)

pen <- penalized(Surv(time, event), penalized = nki70[1:50,8:77],
    unpenalized = ~ER+Age+Diam+N+Grade, data = nki70[1:50,], lambda1 = 10)

predict(pen, nki70[51:52,8:77], data = nki70[51:52,])
# }

Run the code above in your browser using DataLab